# Compiler and flags
CXX := g++
CXXFLAGS := -std=c++17 -Wall -Wextra -pthread
DEBUG_FLAGS := -g
RELEASE_FLAGS := -O3

# Target executable
TARGET := thread_pool_demo

# Source files
SRCS := TaskQueue.cpp ThreadPool.cpp main.cpp
OBJS := $(SRCS:.cpp=.o)
DEPS := $(OBJS:.o=.d)

# Default build (debug)
all: debug

# Debug build
debug: CXXFLAGS += $(DEBUG_FLAGS)
debug: $(TARGET)

# Release build
release: CXXFLAGS += $(RELEASE_FLAGS)
release: $(TARGET)

# Link object files into executable
$(TARGET): $(OBJS)
	$(CXX) $(CXXFLAGS) $^ -o $@

# Compile .cpp to .o + generate dependencies
%.o: %.cpp
	$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@

# Include auto-generated dependencies
-include $(DEPS)

# Clean build artifacts
clean:
	rm -f $(TARGET) $(OBJS) $(DEPS)

.PHONY: all debug release clean